package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 朋友圈评论/回复
 */
@Getter
@Setter
public class FriendNewsComment extends BaseDomain implements Comparable<FriendNewsComment>{
    //好友动态
    private FriendNews friendNews;
    //被回复人
    private User byUser;
    //评论内容
    private String content;
    //评论日期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date commentDate;
    //回复人
    private User reply;
    //是否已读
    private Boolean isViewed=false;

    @Override
    public int compareTo(FriendNewsComment o) {
        if (o.getCommentDate() != null) {
            if (DateUtil.after(this.getCommentDate(), o.getCommentDate())) {
                return -1;
            } else if (DateUtil.after(o.getCommentDate(), this.getCommentDate())) {
                return 1;
            }
        }
        return 0;
    }
}
